package com.wu.creditmanager.util;

import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.adview.AdViewLayout;
import com.wu.creditmanager.R;

public class LayoutUtil {

	public static void initToolbar(View tbar, String titleResId,
			String btn1Text, OnClickListener btn1ClickListener,
			String btn2Text, OnClickListener btn2ClickListener) {
		TextView title = (TextView) tbar.findViewById(R.id.tbar_textview);
		title.setText(titleResId);
		Button button1 = (Button) tbar.findViewById(R.id.tbar_btn1);
		if (btn1Text == null) {
			button1.setVisibility(View.GONE);
		} else {
			button1.setText(btn1Text);
			button1.setOnClickListener(btn1ClickListener);
		}
		Button button2 = (Button) tbar.findViewById(R.id.tbar_btn2);
		if (btn2Text == null) {
			button2.setVisibility(View.GONE);
		} else {
			button2.setText(btn2Text);
			button2.setOnClickListener(btn2ClickListener);
		}
	}

	public static void initAdLayout(Activity activity) {
		LinearLayout layout = (LinearLayout) activity
				.findViewById(R.id.adLayout);
		AdViewLayout adViewLayout = new AdViewLayout(activity,
				Constants.ADVIEWKEY);
		layout.addView(adViewLayout);
		layout.invalidate();
	}

}
